package com.kuangstudy.thread.demo3;

/**
 * @author Losca
 * @date 2021/7/19 20:46
 */
public class Demo6 {
    public static void main(String[] args) {
        You you = new You();
        God god = new God();
        Thread thread = new Thread(you);
        Thread thread1 = new Thread(god);
        thread1.setDaemon(true);//设置守护线程
        thread1.start();
        thread.start();

    }
}

class You implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println("用户线程");
        }
    }
}

class God implements Runnable{

    @Override
    public void run() {
        while (true){
            System.out.println("守护线程");
        }
    }
}
